const fs = require("fs");

const delay = (time) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      console.log(123);
      resolve("等待结束了");
    }, time);
  });
};

const read = (url) => {
  return new Promise((resolve, reject) => {
    fs.readFile(url, "utf-8", (err, data) => {
      if (err) throw err;
      resolve(data);
    });
  });
};

delay(2000)
  .then((res) => {
    console.log(res);
    return read("./01-事件.html");
  })
  .then((res) => {
    console.log(res);
    return read("./02-回调函数.js");
  })
  .then((res) => {
    console.log(res);
  });
